package com.hccl.mongoEntities.step;

import DM.StateMachine;
import com.hccl.mongoEntities.NoMatchOrInputEntity;
import entities.Reply;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xjzhang on 2017/11/23.
 */
public class ASRStep extends Step{

    NoMatchOrInputEntity noMatch;
    NoMatchOrInputEntity noInput;

    boolean jumpOut = true;

    protected  Reply noParamReply;

    String checkParamJs;


    public ASRStep(){
        super();
    }

    @Override
    public void run(StateMachine stateMachine) throws Exception{

    }

    public void interrupt(StateMachine stateMachine) throws Exception{
        stateMachine.getProcessThread().setWhetherInterrupt(true);
        //唤醒主线程
        stateMachine.getLocker().lock();
        try {
            stateMachine.addDialogReply(noParamReply);
            stateMachine.getStateMachineCondition().signal();
        }finally {
            stateMachine.getLocker().unlock();
        }
        //让process线程等待
        stateMachine.getProcessThread().getLocker().lock();
        try {
            stateMachine.getProcessThread().getCondition().await();
        }finally {
            stateMachine.getProcessThread().getLocker().unlock();
        }
    }

    @Override
    public void onExit(StateMachine stateMachine){
//        logger.info(name+"step结束执行");
//        stateMachine.setCurrentStep(null);
    }

    @Override
    public void onEnter(StateMachine stateMachine){
//        logger.info(name + "step开始执行");
//        stateMachine.setCurrentStep(this);
    }

    public NoMatchOrInputEntity getNoMatch() {
        return noMatch;
    }

    public void setNoMatch(NoMatchOrInputEntity noMatch) {
        this.noMatch = noMatch;
    }

    public NoMatchOrInputEntity getNoInput() {
        return noInput;
    }

    public void setNoInput(NoMatchOrInputEntity noInput) {
        this.noInput = noInput;
    }

    public boolean isJumpOut() {
        return jumpOut;
    }

    public void setJumpOut(boolean jumpOut) {
        this.jumpOut = jumpOut;
    }

    public Reply getNoParamReply() {
        return noParamReply;
    }

    public void setNoParamReply(Reply noParamReply) {
        this.noParamReply = noParamReply;
    }

    public String getCheckParamJs() {
        return checkParamJs;
    }

    public void setCheckParamJs(String checkParamJs) {
        this.checkParamJs = checkParamJs;
    }
}
